\(\int (c+d x)^2 \cos (a+b x) \, dx\) [3]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 49 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\frac {2 d (c+d x) \cos (a+b x)}{b^2}-\frac {2 d^2 \sin (a+b x)}{b^3}+\frac {(c+d x)^2 \sin (a+b x)}{b} \]

[Out]

2*d*(d*x+c)*cos(b*x+a)/b^2-2*d^2*sin(b*x+a)/b^3+(d*x+c)^2*sin(b*x+a)/b

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3377, 2717} \[ \int (c+d x)^2 \cos (a+b x) \, dx=-\frac {2 d^2 \sin (a+b x)}{b^3}+\frac {2 d (c+d x) \cos (a+b x)}{b^2}+\frac {(c+d x)^2 \sin (a+b x)}{b} \]

[In]

Int[(c + d*x)^2*Cos[a + b*x],x]

[Out]

(2*d*(c + d*x)*Cos[a + b*x])/b^2 - (2*d^2*Sin[a + b*x])/b^3 + ((c + d*x)^2*Sin[a + b*x])/b

Rule 2717

Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 3377

Int[((c_.) + (d_.)*(x_))^(m_.)*sin[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[(-(c + d*x)^m)*(Cos[e + f*x]/f), x]
+ Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Cos[e + f*x], x], x] /; FreeQ[{c, d, e, f}, x] && GtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(c+d x)^2 \sin (a+b x)}{b}-\frac {(2 d) \int (c+d x) \sin (a+b x) \, dx}{b} \\ & = \frac {2 d (c+d x) \cos (a+b x)}{b^2}+\frac {(c+d x)^2 \sin (a+b x)}{b}-\frac {\left (2 d^2\right ) \int \cos (a+b x) \, dx}{b^2} \\ & = \frac {2 d (c+d x) \cos (a+b x)}{b^2}-\frac {2 d^2 \sin (a+b x)}{b^3}+\frac {(c+d x)^2 \sin (a+b x)}{b} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.17 (sec) , antiderivative size = 44, normalized size of antiderivative = 0.90 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\frac {2 b d (c+d x) \cos (a+b x)+\left (-2 d^2+b^2 (c+d x)^2\right ) \sin (a+b x)}{b^3} \]

[In]

Integrate[(c + d*x)^2*Cos[a + b*x],x]

[Out]

(2*b*d*(c + d*x)*Cos[a + b*x] + (-2*d^2 + b^2*(c + d*x)^2)*Sin[a + b*x])/b^3

Maple [A] (verified)

Time = 0.90 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.22

method result size
risch \(\frac {2 d \left (d x +c \right ) \cos \left (b x +a \right )}{b^{2}}+\frac {\left (x^{2} d^{2} b^{2}+2 b^{2} c d x +b^{2} c^{2}-2 d^{2}\right ) \sin \left (b x +a \right )}{b^{3}}\) \(60\)
parallelrisch \(\frac {-2 d^{2} \left (\tan ^{2}\left (\frac {b x}{2}+\frac {a}{2}\right )\right ) x b +\left (2 \left (d x +c \right )^{2} b^{2}-4 d^{2}\right ) \tan \left (\frac {b x}{2}+\frac {a}{2}\right )+4 b d \left (\frac {d x}{2}+c \right )}{b^{3} \left (1+\tan ^{2}\left (\frac {b x}{2}+\frac {a}{2}\right )\right )}\) \(77\)
parts \(\frac {\sin \left (b x +a \right ) x^{2} d^{2}}{b}+\frac {2 \sin \left (b x +a \right ) c d x}{b}+\frac {\sin \left (b x +a \right ) c^{2}}{b}-\frac {2 d \left (\frac {d a \cos \left (b x +a \right )}{b}-c \cos \left (b x +a \right )+\frac {d \left (\sin \left (b x +a \right )-\left (b x +a \right ) \cos \left (b x +a \right )\right )}{b}\right )}{b^{2}}\) \(98\)
norman \(\frac {\frac {4 c d}{b^{2}}+\frac {2 d^{2} x}{b^{2}}+\frac {2 \left (b^{2} c^{2}-2 d^{2}\right ) \tan \left (\frac {b x}{2}+\frac {a}{2}\right )}{b^{3}}+\frac {2 d^{2} x^{2} \tan \left (\frac {b x}{2}+\frac {a}{2}\right )}{b}-\frac {2 d^{2} x \left (\tan ^{2}\left (\frac {b x}{2}+\frac {a}{2}\right )\right )}{b^{2}}+\frac {4 c d x \tan \left (\frac {b x}{2}+\frac {a}{2}\right )}{b}}{1+\tan ^{2}\left (\frac {b x}{2}+\frac {a}{2}\right )}\) \(118\)
derivativedivides \(\frac {\frac {a^{2} d^{2} \sin \left (b x +a \right )}{b^{2}}-\frac {2 a c d \sin \left (b x +a \right )}{b}-\frac {2 a \,d^{2} \left (\cos \left (b x +a \right )+\left (b x +a \right ) \sin \left (b x +a \right )\right )}{b^{2}}+c^{2} \sin \left (b x +a \right )+\frac {2 c d \left (\cos \left (b x +a \right )+\left (b x +a \right ) \sin \left (b x +a \right )\right )}{b}+\frac {d^{2} \left (\left (b x +a \right )^{2} \sin \left (b x +a \right )-2 \sin \left (b x +a \right )+2 \left (b x +a \right ) \cos \left (b x +a \right )\right )}{b^{2}}}{b}\) \(143\)
default \(\frac {\frac {a^{2} d^{2} \sin \left (b x +a \right )}{b^{2}}-\frac {2 a c d \sin \left (b x +a \right )}{b}-\frac {2 a \,d^{2} \left (\cos \left (b x +a \right )+\left (b x +a \right ) \sin \left (b x +a \right )\right )}{b^{2}}+c^{2} \sin \left (b x +a \right )+\frac {2 c d \left (\cos \left (b x +a \right )+\left (b x +a \right ) \sin \left (b x +a \right )\right )}{b}+\frac {d^{2} \left (\left (b x +a \right )^{2} \sin \left (b x +a \right )-2 \sin \left (b x +a \right )+2 \left (b x +a \right ) \cos \left (b x +a \right )\right )}{b^{2}}}{b}\) \(143\)
meijerg \(\frac {4 d^{2} \cos \left (a \right ) \sqrt {\pi }\, \left (\frac {x \left (b^{2}\right )^{\frac {3}{2}} \cos \left (b x \right )}{2 \sqrt {\pi }\, b^{2}}-\frac {\left (b^{2}\right )^{\frac {3}{2}} \left (-\frac {3 x^{2} b^{2}}{2}+3\right ) \sin \left (b x \right )}{6 \sqrt {\pi }\, b^{3}}\right )}{b^{2} \sqrt {b^{2}}}-\frac {4 d^{2} \sin \left (a \right ) \sqrt {\pi }\, \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\left (-\frac {x^{2} b^{2}}{2}+1\right ) \cos \left (b x \right )}{2 \sqrt {\pi }}+\frac {x b \sin \left (b x \right )}{2 \sqrt {\pi }}\right )}{b^{3}}+\frac {4 d c \cos \left (a \right ) \sqrt {\pi }\, \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\cos \left (b x \right )}{2 \sqrt {\pi }}+\frac {x b \sin \left (b x \right )}{2 \sqrt {\pi }}\right )}{b^{2}}-\frac {4 d c \sin \left (a \right ) \sqrt {\pi }\, \left (-\frac {x b \cos \left (b x \right )}{2 \sqrt {\pi }}+\frac {\sin \left (b x \right )}{2 \sqrt {\pi }}\right )}{b^{2}}+\frac {c^{2} \cos \left (a \right ) \sin \left (b x \right )}{b}-\frac {c^{2} \sin \left (a \right ) \sqrt {\pi }\, \left (\frac {1}{\sqrt {\pi }}-\frac {\cos \left (b x \right )}{\sqrt {\pi }}\right )}{b}\) \(225\)

[In]

int((d*x+c)^2*cos(b*x+a),x,method=_RETURNVERBOSE)

[Out]

2*d*(d*x+c)*cos(b*x+a)/b^2+(b^2*d^2*x^2+2*b^2*c*d*x+b^2*c^2-2*d^2)/b^3*sin(b*x+a)

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.27 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\frac {2 \, {\left (b d^{2} x + b c d\right )} \cos \left (b x + a\right ) + {\left (b^{2} d^{2} x^{2} + 2 \, b^{2} c d x + b^{2} c^{2} - 2 \, d^{2}\right )} \sin \left (b x + a\right )}{b^{3}} \]

[In]

integrate((d*x+c)^2*cos(b*x+a),x, algorithm="fricas")

[Out]

(2*(b*d^2*x + b*c*d)*cos(b*x + a) + (b^2*d^2*x^2 + 2*b^2*c*d*x + b^2*c^2 - 2*d^2)*sin(b*x + a))/b^3

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 112 vs. \(2 (48) = 96\).

Time = 0.20 (sec) , antiderivative size = 112, normalized size of antiderivative = 2.29 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\begin {cases} \frac {c^{2} \sin {\left (a + b x \right )}}{b} + \frac {2 c d x \sin {\left (a + b x \right )}}{b} + \frac {d^{2} x^{2} \sin {\left (a + b x \right )}}{b} + \frac {2 c d \cos {\left (a + b x \right )}}{b^{2}} + \frac {2 d^{2} x \cos {\left (a + b x \right )}}{b^{2}} - \frac {2 d^{2} \sin {\left (a + b x \right )}}{b^{3}} & \text {for}\: b \neq 0 \\\left (c^{2} x + c d x^{2} + \frac {d^{2} x^{3}}{3}\right ) \cos {\left (a \right )} & \text {otherwise} \end {cases} \]

[In]

integrate((d*x+c)**2*cos(b*x+a),x)

[Out]

Piecewise((c**2*sin(a + b*x)/b + 2*c*d*x*sin(a + b*x)/b + d**2*x**2*sin(a + b*x)/b + 2*c*d*cos(a + b*x)/b**2 +
 2*d**2*x*cos(a + b*x)/b**2 - 2*d**2*sin(a + b*x)/b**3, Ne(b, 0)), ((c**2*x + c*d*x**2 + d**2*x**3/3)*cos(a),
True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 136 vs. \(2 (49) = 98\).

Time = 0.33 (sec) , antiderivative size = 136, normalized size of antiderivative = 2.78 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\frac {c^{2} \sin \left (b x + a\right ) - \frac {2 \, a c d \sin \left (b x + a\right )}{b} + \frac {a^{2} d^{2} \sin \left (b x + a\right )}{b^{2}} + \frac {2 \, {\left ({\left (b x + a\right )} \sin \left (b x + a\right ) + \cos \left (b x + a\right )\right )} c d}{b} - \frac {2 \, {\left ({\left (b x + a\right )} \sin \left (b x + a\right ) + \cos \left (b x + a\right )\right )} a d^{2}}{b^{2}} + \frac {{\left (2 \, {\left (b x + a\right )} \cos \left (b x + a\right ) + {\left ({\left (b x + a\right )}^{2} - 2\right )} \sin \left (b x + a\right )\right )} d^{2}}{b^{2}}}{b} \]

[In]

integrate((d*x+c)^2*cos(b*x+a),x, algorithm="maxima")

[Out]

(c^2*sin(b*x + a) - 2*a*c*d*sin(b*x + a)/b + a^2*d^2*sin(b*x + a)/b^2 + 2*((b*x + a)*sin(b*x + a) + cos(b*x +
a))*c*d/b - 2*((b*x + a)*sin(b*x + a) + cos(b*x + a))*a*d^2/b^2 + (2*(b*x + a)*cos(b*x + a) + ((b*x + a)^2 - 2
)*sin(b*x + a))*d^2/b^2)/b

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 64, normalized size of antiderivative = 1.31 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\frac {2 \, {\left (b d^{2} x + b c d\right )} \cos \left (b x + a\right )}{b^{3}} + \frac {{\left (b^{2} d^{2} x^{2} + 2 \, b^{2} c d x + b^{2} c^{2} - 2 \, d^{2}\right )} \sin \left (b x + a\right )}{b^{3}} \]

[In]

integrate((d*x+c)^2*cos(b*x+a),x, algorithm="giac")

[Out]

2*(b*d^2*x + b*c*d)*cos(b*x + a)/b^3 + (b^2*d^2*x^2 + 2*b^2*c*d*x + b^2*c^2 - 2*d^2)*sin(b*x + a)/b^3

Mupad [B] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.71 \[ \int (c+d x)^2 \cos (a+b x) \, dx=\frac {d^2\,x^2\,\sin \left (a+b\,x\right )}{b}-\frac {\sin \left (a+b\,x\right )\,\left (2\,d^2-b^2\,c^2\right )}{b^3}+\frac {2\,c\,d\,\cos \left (a+b\,x\right )}{b^2}+\frac {2\,d^2\,x\,\cos \left (a+b\,x\right )}{b^2}+\frac {2\,c\,d\,x\,\sin \left (a+b\,x\right )}{b} \]

[In]

int(cos(a + b*x)*(c + d*x)^2,x)

[Out]

(d^2*x^2*sin(a + b*x))/b - (sin(a + b*x)*(2*d^2 - b^2*c^2))/b^3 + (2*c*d*cos(a + b*x))/b^2 + (2*d^2*x*cos(a +
b*x))/b^2 + (2*c*d*x*sin(a + b*x))/b